			$(function(){
				search();
			});
		
			function search(){
				var searchParam = JSON.stringify({
					username:$("#userName").val(),
					department:$("#department").val(),
					startTime:$("#startTime").val(),
					endTime:$("#endTime").val(),
					pageNum:$("#pageNum").val(),
					pageSize:$("#pageSize").val()
				});
				$.ajax({
		            url : "/user",
		            data : searchParam,
		            type : 'PATCH',
		            dataType : 'json',
		            contentType : 'application/json',
		            success : successFunc,
		            error : errorFunc
			    });
			}
			
			function successFunc(data) {
				if(data != null){
					var list = data.list;
					var innerHtml = "";
					var createtime = "";
					var username = "";
					var truename = "";
					var department = "";
					var role = "";
					var id = "";
					var num = (data.pageNum-1)*data.pageSize;
					$.each(list, function(i, row){
						createtime = formatJSONDate(row.createtime);
						username = row.username == null?"":row.username;
						truename =  row.truename == null?"":row.truename;
						department = row.department == null?"":row.department;
						role = row.role == null?"":row.role;
						id = row.id;
						innerHtml += "<tr <c:if test='${i%2==0}'> class='odd'</c:if>>" 
										+ "<td algin='center'><span class='entityList'>"+(num+i+1)+"</td>"
										+ "<td algin='center'><span class='entityList'>"+username+"</td>"
										+ "<td algin='center'><span class='entityList'>"+truename+"</td>"
										+ "<td algin='center'><span class='entityList'>"+department+"</td>"
										+ "<td algin='center'><span class='entityList'>"+role+"</td>"
										+ "<td algin='center'><span class='entityList'>"+createtime+"</td>"
										+ "<td algin='center'><span class='entityList'><a href='javascript:getUser("+id+")'>修改</a>&nbsp;<a href='javascript:deleteUser("+id+")'>删除</a></td>"
										+ "</tr>"
						createtime = "";
						username = "";
						truename = "";
						department = "";
						role = "";
					})
					$("#msg").html(innerHtml);
					
					//加载分页
					pageHelper(data);
				}else{
					alert("获取数据失败！");
				}
		    }
		    function errorFunc(data) {
		    	alert("获取数据失败！");
		    }
		    
		    //删除方法
		    function deleteUser(id){
		    	$.ajax({
		            url : "/user/"+id,
		            type : 'DELETE',
		            dataType : 'json',
		            contentType : 'application/json',
		            success : function(data){
		            	if(data.message != null && data.message != ""){
							alert(data.message);
							search();
						}
		            },
		            error : function(data){
		            	alert("删除用户失败！");
		            }
			    });
		    }
		    
		    //修改用户
		    function getUser(id) {
		    	var url = "/user/"+id;
		    	window.location.href=url;
			}